package com.rs.game.player.dialogues;

import com.rs.game.player.Skills;

public class Tanner extends Dialogue {
	
	private int npcId;
	private int hides;

	@Override
	public void start() {
		npcId = (int) parameters[0];
		sendNPCDialogue(npcId, Expressions.NORMAL, "Would you like to tan your hides?");
	}

	@Override
	public void run(int interfaceId, int componentId) {
		switch (stage) {
		case -1:
			sendOptionsDialogue("Select an Option", "Cowhide - Leather 2GP", "Cowhide - Hard Leather 5GP", "Snake hide - Snakeskin 45GP", "Dragon Leather");
			stage = 0;
			break;
		case 0:
			switch (componentId) {
			case OPTION_1:
				hides = player.getInventory().getNumerOf(1739);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 1) {
						if (player.getInventory().containsItem(995, 0) && player.getInventory().containsItem(1739, 1)) {
							player.getInventory().deleteItem(1739, 1);
							player.getInventory().deleteItem(995, 0);
							player.getInventory().addItem(1741, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 1 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_2:
				hides = player.getInventory().getNumerOf(1739);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 28) {
						if (player.getInventory().containsItem(995, 5) && player.getInventory().containsItem(1739, 1)) {
							player.getInventory().deleteItem(1739, 1);
							player.getInventory().deleteItem(995, 5);
							player.getInventory().addItem(1743, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 28 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_3:
				hides = player.getInventory().getNumerOf(6287);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 45) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(6287, 1)) {
							player.getInventory().deleteItem(6287, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(6289, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 45 to tan this.");
						end();
						break;
					}
				}
				break;
			case OPTION_4:
				sendOptionsDialogue("Select an Option", "Green Dragon - 45GP", "Blue Dragon - 45GP", "Red Dragon - 45GP", "Black Dragon - 45GP", "Royal Dragon - 45GP");
				stage = 1;
				break;
			}
			break;
		case 1:
			switch (componentId) {
			case OPTION_1:
				hides = player.getInventory().getNumerOf(1753);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 57) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(1753, 1)) {
							player.getInventory().deleteItem(1753, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(1743, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 57 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_2:
				hides = player.getInventory().getNumerOf(1751);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 66) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(1751, 1)) {
							player.getInventory().deleteItem(1751, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(2505, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 66 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_3:
				hides = player.getInventory().getNumerOf(1749);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 73) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(1749, 1)) {
							player.getInventory().deleteItem(1749, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(2507, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 73 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_4:
				hides = player.getInventory().getNumerOf(1747);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 79) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(1747, 1)) {
							player.getInventory().deleteItem(1747, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(2509, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 79 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			case OPTION_5:
				hides = player.getInventory().getNumerOf(24372);
				
				for (int i = 0; i < hides; i++) {
					if (player.getSkills().getLevelForXp(Skills.CRAFTING) >= 87) {
						if (player.getInventory().containsItem(995, 45) && player.getInventory().containsItem(24372, 1)) {
							player.getInventory().deleteItem(24372, 1);
							player.getInventory().deleteItem(995, 45);
							player.getInventory().addItem(24374, 1);
						} else {
							player.getPackets().sendGameMessage("You don't have enough supplies to tan that.");
							end();
							break;
						}
					} else {
						player.getPackets().sendGameMessage("You need a Crafting level of 87 to tan this.");
						end();
						break;
					}
				}
				end();
				break;
			}
			break;
		}
	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		
	}
	
}